<?php

/**
 * Description of UserInfoModel
 *
 * @author chacha
 * @date 2016-7-23
 */
class UserInfoModel extends Model{
    protected $uid = 0;
    
    public function __construct($uid) {
        parent::__construct();
        $this->uid = $uid;
    }
    
    //修改真实姓名
    public function changeRealname($newname) {
        $this->find($this->uid);
        $oldname = $this->realname;
        if (isset($oldname) && !empty($oldname)) {
            $this->error = "已设置过真实姓名：{$oldname}，无法再次更改";
            return false;
        }
        if ($this->where("uid=".$this->uid)->save(array("realname"=>$newname))) {
            return true;
        }
        $this->error = "服务器内部错误，设置失败。";
        return false;
    }
}
